package com.xj.controller;


import com.xj.server.DatabaseBackService;
import com.xj.server.ExecuteCommandServer;
import com.xj.server.ReadfileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@Slf4j
public class ApiController {
   @Autowired
 private ReadfileService readfileService;
  @Autowired
  private ExecuteCommandServer executeCommandServer;
   @Autowired
   private DatabaseBackService databaseBackService;


  @GetMapping(value = "/day")
    public @ResponseBody
    String  udpateDalayDay() throws Exception{
        readfileService.outputFile();
        return "updateDelayDay";
  }

  @GetMapping(value = "/restart")
    public @ResponseBody
    String  restartServer()  throws Exception{
      executeCommandServer.executRestart();
      return "restart";
  }


    @GetMapping(value = "/back")
    public @ResponseBody
    String  back()  throws Exception{
        databaseBackService.executeBack();
        return "restart";
    }

}
